package nl.mayisal.startup;

import java.sql.SQLException;

import nl.mayisal.metadata.DatabaseStructure;
import nl.mayisal.metadata.TableStructure;
import nl.mayisal.metadata.factories.DatabaseStructureFactory;
import nl.mayisal.sql.SQLConnection;
import nl.mayisal.sql.SQLConnector;

public class Analyser {


	/**
	 * @param args
	 * @throws SQLException 
	 * @throws ClassNotFoundException 
	 */
	public static void main(String[] args) throws SQLException, ClassNotFoundException {
		SQLConfig.initialize("sqlconfig.properties");

		SQLConnection connection = new SQLConnector().getConnection();
		DatabaseStructure structure = DatabaseStructureFactory.createStructure(connection);
		connection.close();
		ThreadGroup group = new ThreadGroup("Table Analysers");
		for (TableStructure table : structure.getTables().values()) {
			new Thread(group, new TableAnalyser(table),"Analyze "+table.getName()).start();
		}
		System.out.println("Analysis completed");
	}
}
